import { Controller,Body,Post } from '@nestjs/common'
import { Message } from './message.entity'
import { MessageService } from './message.service'
import { Response } from '../common/Response'

@Controller('/message')
export class MessageController {
    constructor(private readonly messageService: MessageService){}

    @Post('/history/record')
    async getHistoryMessage(@Body() body):Promise<Response<Message[]>>{
        try {
            const res = await this.messageService.getHistoryMsg()
            return {
                code:0,
                status:'ok',
                data: res
            }
        } catch (error) {
            console.log(error);
            return {
                code: -1,
                status:'error',
                msg: '查询历史消息失败'
            }
        }
    }
}